import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

import vue from '@vitejs/plugin-vue'

export default defineConfig({
	plugins: [
		vue({
			script: {
				defineModel: true,
			},
		}),
		AutoImport({
			resolvers: [ElementPlusResolver()],
		}),
		Components({
			resolvers: [ElementPlusResolver()],
		}),
	],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url)),
			'@stu': fileURLToPath(new URL('./src/views/student', import.meta.url)),
			'@pinia': fileURLToPath(new URL('./src/stores', import.meta.url)),
			'@tea': fileURLToPath(new URL('./src/views/teather', import.meta.url)),
			'@mast': fileURLToPath(new URL('./src/views/admin_master', import.meta.url)),
			'@dom': fileURLToPath(new URL('./src/views/admin_domitory', import.meta.url)),
			'@com': fileURLToPath(new URL('./src/components', import.meta.url)),
		},
	},
	base: './',
	server: {
		proxy: {
			'/api': {
				target: 'http://8.130.68.204:9090',
				// target:"http://192.168.13.25:8023",
				// target:"http://192.168.179.1:8080",
				// target:"http://10.7.37.220:8023",
				rewrite: (path) => path.replace(/^\/api/, ''),
			},
		},
	},
})
